package com.dream.dream.controller;

import com.dream.dream.service.SsqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/dream")
public class GetController {

    @Autowired
    RestTemplate restTemplate;

    @Autowired
    SsqService ssqService;


    public final static int limit = 500;

    public static int allPage;

    public final String url = "http://api.huiniao.top/interface/home/lotteryHistory?type=dlt&page= ";


    /**
     * 获取最新数据
     */
    @RequestMapping("/get")
    public String getNewData() {

        ssqService.getData();
        return "ok";
    }


    /**
     * 获取全部数据
     *
     * @return
     */
    @RequestMapping("/getAll")
    public String get() {
        // 删除数据表中所有数据
        ssqService.remove(null);
        int allData = ssqService.getAllData();
        if(allData != 0){
            return "error";
        }
        return "ok";
    }







}
